import java.io.File;
import java.io.FileFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class DirList {
	public static List<String> list(String directory, FileFilter filter) {
		File dir = new File(directory);
		List<String> result = new ArrayList<String>();

		File[] children = dir.listFiles(filter);
		if (children == null) {
			// Either dir does not exist or is not a directory
		} else {
			for (int i = 0; i < children.length; i++) {
				// Get filename of file or directory
				String filename = children[i].getName();
				result.add(filename);
			}
		}
		Collections.sort(result);
		return result;
	}

	public static final FileFilter dirFilter = new FileFilter() {
		public boolean accept(File file) {
			return file.isDirectory();
		}
	};

}
